<% if my_module.blank? and @my_module.present? then my_module = @my_module end %>
<% if order.blank? and @order.present? then order = @order end %>
<% timestamp = Time.current + 1.year - 2.days %>
<% activities = ActivitiesService.my_module_activities(my_module).order(created_at: order) %>
<div class="report-element report-module-activity-element" data-ts="<%= timestamp.to_i %>" data-type="my_module_activity" data-id='{ "my_module_id": <%= my_module.id %> }' data-scroll-id="<%= my_module.id %>" data-order="<%= order == :asc ? "asc" : "desc" %>" data-name="<%=t "projects.reports.elements.module_activity.sidebar_name" %>" data-icon-class="fas fa-list">
  <div class="report-element-header">
    <div class="row">
      <div class="pull-left activity-icon">
        <span class="fas fa-list"></span>
      </div>
      <div class="pull-left activity-name">
        <%=t "projects.reports.elements.module_activity.name", my_module: my_module.name %>
      </div>
      <div class="pull-right controls">
        <%= render partial: "reports/elements/element_controls.html.erb", locals: { show_sort: true } %>
      </div>
    </div>
  </div>
  <div class="report-element-body">
    <div class="row">
      <div class="col-xs-12 activity-container">
        <% if activities.any? %>
          <!-- TODO: This might become potentially very big! -->
          <ul class="no-style activity-list">
            <% activities.each do |activity| %>
              <% activity_ts = activity.created_at %>
              <li class="activity" data-ts="<%= activity_ts.to_i %>">
                <span class="activity-prefix">
                  <%=l activity_ts, format: :full %>
                </span>
                <span class="activity-message">
                  &nbsp;
                  <% if activity.old_activity?  %>
                    <%= sanitize_input(activity.message) %>
                  <% else %>
                    <%= sanitize_input(generate_activity_content(activity, true)) %>
                  <% end %>
                </span>
              </li>
            <% end %>
          </ul>
        <% else %>
          <em><%=t "projects.reports.elements.module_activity.no_activity" %></em>
        <% end %>
      </div>
    </div>
  </div>
  <div class="report-element-children">
    <%= children if (defined? children and children.present?) %>
  </div>
</div>
